<?php
require ('../include/init.inc.php');
 $method  = $user_id = $page_no = $search = $tr_id='';
extract ( $_REQUEST, EXTR_IF_EXISTS );

if ($method == 'del' && ! empty ( $tr_id )) {
	
		$tOrder= TouristOrder::getTouristOrderById($tr_id);
		$result = TouristOrder::delTouristOrder($tr_id);
		if ($result>=0) {
			$user['password']=null;
			SysLog::addLog ( UserSession::getUserName(), 'DELETE',  'TouristOrder' ,$tr_id ,json_encode($tOrder) );
			Common::exitWithSuccess ( '已删除','panel/tourist_orders.php' );
		}else{
			OSAdmin::alert("error");
		}
	
}

//START 数据库查询及分页数据
$page_size = PAGE_SIZE;
$page_no=$page_no<1?1:$page_no;

if($search){
	$row_count = User::countSearch($user_group,$user_name);
	$total_page=$row_count%$page_size==0?$row_count/$page_size:ceil($row_count/$page_size);
	$total_page=$total_page<1?1:$total_page;
	$page_no=$page_no>($total_page)?($total_page):$page_no;
	$start = ($page_no - 1) * $page_size;
	$user_infos = User::search($user_group,$user_name,$start , $page_size);
	
}else{
	$row_count = TouristOrder::count ();
	$total_page=$row_count%$page_size==0?$row_count/$page_size:ceil($row_count/$page_size);
	$total_page=$total_page<1?1:$total_page;
	$page_no=$page_no>($total_page)?($total_page):$page_no;
	$start = ($page_no - 1) * $page_size;
	$tourist_orders = TouristOrder::getTouristOrders( $start , $page_size );
}

$page_html=Pagination::showPager("tourist_orders.php?",$page_no,$page_size,$row_count);

//追加操作的确认层
$confirm_html = OSAdmin::renderJsConfirm("icon-pause,icon-play,icon-remove");

// 设置模板变量
Template::assign ( 'tourist_conf', $baseConf["touristOrder"] );
Template::assign ( 'tourist_orders', $tourist_orders );
Template::assign ( '_GET', $_GET );
Template::assign ( 'page_no', $page_no );
Template::assign ( 'page_html', $page_html );
Template::assign ( 'osadmin_action_confirm' , $confirm_html);
Template::display ( 'panel/tourist_orders.tpl' );
